﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using MediaBrowser;
using MediaBrowser.Library;
using Microsoft.MediaCenter.UI;
using Application=MediaBrowser.Application;

namespace Chocolate
{
    public class ChocHelper : ModelItem
    {
        private Item _currentItem;

        public Item CurrentItem
        {
            get
            {
                return _currentItem;
            }
            set
            {
                _currentItem = value;
                FirePropertyChanged("EndTime");
            }
        }

        public string EndTime
        {
            get
            {
                return calculateEndTime();
                
            }
            
        }
        public ChocHelper()
        {
            Config = new MyConfig();
            
        }

        public ChocHelper( Item Item)
        {
            CurrentItem = Item;
            
        }
        private string calculateEndTime()
        {
            string runtime = CurrentItem.RunningTimeString;

            if(runtime != "")
            {
                runtime = runtime.Replace(" mins", "");
                int minutes = Int32.Parse(runtime);
                DateTime dt = DateTime.Now;
                dt = dt.AddMinutes(minutes);

                int Hour = dt.Hour;
                if(dt.Hour > 12)
                {
                    Hour = Hour - 12;
                }

                if (dt.Minute > 9)
                {
                    return Hour.ToString() + ":" + dt.Minute.ToString();
                }
                else
                {
                    return Hour.ToString() + ":0" + dt.Minute.ToString();
                }


            }
            return "";
        }


        public bool IsMenuOpen
        { get; set; }

        public MyConfig Config
        { get; set; }
        
    }
}
